*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      mec_wage.do                                     *;
*       Date:           12/28/2020                                      *;
*       Authora:        Baccini, Guidi, Poletti, and Yildirim           *;
*       Purpose:        Replication of "Trade Liberalization and Labor  *;
*						Market Institutions"                            *;                                                                      
*       Input Files:    mec_wage.dta 					         	    *; 
*       Output Files:   mec_wage_logfile.log                            *;
*       Machine:        Office                                          *;
*       Program: 		Stata 15                                        *;
*     ****************************************************************  *;
*     ****************************************************************  *;

* Setting initial commands
clear
clear matrix
clear mata
set maxvar 50000
set matsize 11000
set more off 

* Loading the dataset
*cd "Replication File"
use mec_wage, clear
log using mec_wage_logfile.log

* Figure 4
xtset id1 year
reg d.hw3wuus c.tariff_cut_export##i.coord_dummy i.id_ilo i.id_country i.year if year>2001, cluster(id_country) r
outreg2 using tableD1.xls, bdec(3) tdec(2) addstat(`e(r2_p)') addtext(Controls, No, Country-year fixed effects, No, Industry fixed effects, Yes, Country fixed efects, Yes, Year fixed effects, Yes) keep(c.tariff_cut_export##i.coord_dummy) label append
margins, dydx( tariff_cut_export ) at(coord_dummy=(0(1)1)) level(90)
marginsplot, addplot(histogram coord_dummy,  percent fcolor(none) lcolor(gs5) yaxis(2) yscale(alt  axis(2))) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\NNTT_VoC\Draft\LaTex\IO\Revisions\000 Check\Figure4.gph"
graph save Graph "C:\Users\lbacci\Dropbox\Projects\NNTT_VoC\Draft\LaTex\IO\Revisions\000 Check\Figure4.pdf"
